package com.isdepci.project.eleLoad.controller;

import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.framework.web.page.TableDataInfo;
import com.isdepci.project.eleLoad.domain.AQuotaInformation;
import com.isdepci.project.eleLoad.service.IAQuotaInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 定额信息Controller
 *
 * @author isdepci
 * @date 2025-02-26
 */
@RestController
@RequestMapping("/eleLoad/quota")
public class AQuotaInformationController extends BaseController
{
    @Autowired
    private IAQuotaInformationService aQuotaInformationService;

    /**
     * 查询定额信息列表
     */
    @PreAuthorize("@ss.hasPermi('eleLoad:quota:list')")
    @GetMapping("/list")
    public TableDataInfo list(AQuotaInformation aQuotaInformation)
    {
        startPage();
        List<AQuotaInformation> list = aQuotaInformationService.selectAQuotaInformationList(aQuotaInformation);
        return getDataTable(list);
    }

    /**
     * 导出定额信息列表
     */
    @PreAuthorize("@ss.hasPermi('eleLoad:quota:export')")
    @Log(title = "定额信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AQuotaInformation aQuotaInformation)
    {
        List<AQuotaInformation> list = aQuotaInformationService.selectAQuotaInformationList(aQuotaInformation);
        ExcelUtil<AQuotaInformation> util = new ExcelUtil<AQuotaInformation>(AQuotaInformation.class);
        return util.exportExcel(list, "quota");
    }

    /**
     * 获取定额信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('eleLoad:quota:query')")
    @GetMapping(value = "/{quotaId}")
    public AjaxResult getInfo(@PathVariable("quotaId") Long quotaId)
    {
        return AjaxResult.success(aQuotaInformationService.selectAQuotaInformationById(quotaId));
    }

    /**
     * 新增定额信息
     */
    @PreAuthorize("@ss.hasPermi('eleLoad:quota:add')")
    @Log(title = "定额信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AQuotaInformation aQuotaInformation)
    {
        return toAjax(aQuotaInformationService.insertAQuotaInformation(aQuotaInformation));
    }

    /**
     * 修改定额信息
     */
    @PreAuthorize("@ss.hasPermi('eleLoad:quota:edit')")
    @Log(title = "定额信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AQuotaInformation aQuotaInformation)
    {
        return toAjax(aQuotaInformationService.updateAQuotaInformation(aQuotaInformation));
    }

    /**
     * 删除定额信息
     */
    @PreAuthorize("@ss.hasPermi('eleLoad:quota:remove')")
    @Log(title = "定额信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{quotaIds}")
    public AjaxResult remove(@PathVariable Long[] quotaIds)
    {
        return toAjax(aQuotaInformationService.deleteAQuotaInformationByIds(quotaIds));
    }
}
